import {mapGetters} from "vuex"

export default {
    computed: {
        ...mapGetters('cart',['total'])
    },
    onShow() {
        this.setTabBar()
    },
    watch: {
      total: {
          immediate: true,
          handler(){
              this.setTabBar()
          }
      }
    },
    methods: {
        setTabBar(){
            uni.setTabBarBadge({
                index:2,
                text:`${this.total}`
            })
            if (this.total === 0){
                uni.removeTabBarBadge({
                    index:2
                })
            }
        }
    },
}